/**
 * <copyright>
 * </copyright>
 *

 */
package br.ufpe.cin.plp.eseml.impl;

import br.ufpe.cin.plp.eseml.EsemlPackage;
import br.ufpe.cin.plp.eseml.ExperimentalSubject;
import br.ufpe.cin.plp.eseml.ExperimentalSubjects;
import br.ufpe.cin.plp.eseml.ExperimentalSubjectsValues;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Experimental Subjects</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link br.ufpe.cin.plp.eseml.impl.ExperimentalSubjectsImpl#getExperimentalSubjects <em>Experimental Subjects</em>}</li>
 *   <li>{@link br.ufpe.cin.plp.eseml.impl.ExperimentalSubjectsImpl#getExperimentalSubjectsValues <em>Experimental Subjects Values</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExperimentalSubjectsImpl extends MinimalEObjectImpl.Container implements ExperimentalSubjects
{
  /**
   * The cached value of the '{@link #getExperimentalSubjects() <em>Experimental Subjects</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExperimentalSubjects()
   * @generated
   * @ordered
   */
  protected EList<ExperimentalSubject> experimentalSubjects;

  /**
   * The cached value of the '{@link #getExperimentalSubjectsValues() <em>Experimental Subjects Values</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExperimentalSubjectsValues()
   * @generated
   * @ordered
   */
  protected ExperimentalSubjectsValues experimentalSubjectsValues;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ExperimentalSubjectsImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return EsemlPackage.Literals.EXPERIMENTAL_SUBJECTS;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ExperimentalSubject> getExperimentalSubjects()
  {
    if (experimentalSubjects == null)
    {
      experimentalSubjects = new EObjectContainmentEList<ExperimentalSubject>(ExperimentalSubject.class, this, EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS);
    }
    return experimentalSubjects;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ExperimentalSubjectsValues getExperimentalSubjectsValues()
  {
    return experimentalSubjectsValues;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExperimentalSubjectsValues(ExperimentalSubjectsValues newExperimentalSubjectsValues, NotificationChain msgs)
  {
    ExperimentalSubjectsValues oldExperimentalSubjectsValues = experimentalSubjectsValues;
    experimentalSubjectsValues = newExperimentalSubjectsValues;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES, oldExperimentalSubjectsValues, newExperimentalSubjectsValues);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExperimentalSubjectsValues(ExperimentalSubjectsValues newExperimentalSubjectsValues)
  {
    if (newExperimentalSubjectsValues != experimentalSubjectsValues)
    {
      NotificationChain msgs = null;
      if (experimentalSubjectsValues != null)
        msgs = ((InternalEObject)experimentalSubjectsValues).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES, null, msgs);
      if (newExperimentalSubjectsValues != null)
        msgs = ((InternalEObject)newExperimentalSubjectsValues).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES, null, msgs);
      msgs = basicSetExperimentalSubjectsValues(newExperimentalSubjectsValues, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES, newExperimentalSubjectsValues, newExperimentalSubjectsValues));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS:
        return ((InternalEList<?>)getExperimentalSubjects()).basicRemove(otherEnd, msgs);
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES:
        return basicSetExperimentalSubjectsValues(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS:
        return getExperimentalSubjects();
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES:
        return getExperimentalSubjectsValues();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS:
        getExperimentalSubjects().clear();
        getExperimentalSubjects().addAll((Collection<? extends ExperimentalSubject>)newValue);
        return;
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES:
        setExperimentalSubjectsValues((ExperimentalSubjectsValues)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS:
        getExperimentalSubjects().clear();
        return;
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES:
        setExperimentalSubjectsValues((ExperimentalSubjectsValues)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS:
        return experimentalSubjects != null && !experimentalSubjects.isEmpty();
      case EsemlPackage.EXPERIMENTAL_SUBJECTS__EXPERIMENTAL_SUBJECTS_VALUES:
        return experimentalSubjectsValues != null;
    }
    return super.eIsSet(featureID);
  }

} //ExperimentalSubjectsImpl
